<?php
namespace ff\base;

use ff;
use ff\database\db;
use ff\network\Request;
use ff\view\template;

class Application
{

    public function __construct($config)
    {
        ff::$config = $config;
    }

    private function initComponents()
    {
        if (!isset(ff::$config['components'])) {
            return;
        }
        foreach (ff::$config['components'] as $appComKey => $appComConf) {
            $classname = $appComConf['class'];
            unset($appComConf['class']);

            ff::$app[$appComKey] = ff::createObject($classname, $appComConf);
        }

    }

    /* 业务级 核心方法 */

    public function run()
    {
        $this->initComponents();
        $Router = ff::createObject('ff\network\Router', ['ff\network\Request', 'ff\network\Response']);
        $Router->runController();
    }

}
